/**
 * @file custom.c
 *
 */

/*********************
 *      INCLUDES
 *********************/
#include <stdio.h>
#include "lvgl.h"
#include "custom.h"

char *g_wifi_status = "WIFI_UNKNOW";
lv_ui guider_ui;
/*********************
 *      DEFINES
 *********************/

/**********************
 *      TYPEDEFS
 **********************/

/**********************
 *  STATIC PROTOTYPES
 **********************/

/**********************
 *  STATIC VARIABLES
 **********************/





/**
 * Create a demo application
 */

void custom_init(lv_ui *ui)
{
    /* Add your codes here */
}
int temp_f2c(int f);
int temp_c2f(int c);


void lv_screen_1_update(void)
{
	char temp_buff[50] = {0};
    lv_ui *ui = &guider_ui;

    // lv_label_set_text(ui->screen_1_label_51, (g_UserSet.f_On ? ));
    lv_label_set_text(ui->screen_1_label_4, "64");
    lv_label_set_text(ui->screen_1_label_7, "16");

	snprintf(temp_buff, 50, "%d", g_UserSet.unit ? (temp_c2f(g_UserSet.SetTemp[USER_SET_MODE_HEAT])/10) : g_UserSet.SetTemp[USER_SET_MODE_HEAT]/10);
    lv_label_set_text(ui->screen_1_label_19, temp_buff);
    lv_label_set_text(ui->screen_1_label_21, ".0");
	lv_label_set_text(ui->screen_1_label_18, g_UserSet.unit ? "℉" : "℃");

	snprintf(temp_buff, 50, "%s %d%s", 
			string_env_temp[g_UserSet.Lauguage],
			g_UserSet.unit ? (temp_c2f(180)/10) : 18,
			g_UserSet.unit ? "℉" : "℃");
    lv_label_set_text(ui->screen_1_label_17, temp_buff);

	if (g_UserSet.Lauguage == 0) {
		snprintf(temp_buff, 50, "%d/%02d/%02d  %02d:%02d", 
				g_CurrentRTC.Year + 2000, 
				g_CurrentRTC.Month,
				g_CurrentRTC.Day, 
				g_CurrentRTC.Hour, 
				g_CurrentRTC.Minute);
	} else {
		snprintf(temp_buff, 50, "%02d/%02d/%d  %02d:%02d", 
				g_CurrentRTC.Day, 
				g_CurrentRTC.Month,
				g_CurrentRTC.Year + 2000, 
				g_CurrentRTC.Hour, 
				g_CurrentRTC.Minute);
	}
	lv_label_set_text(ui->screen_1_label_1, temp_buff);

	lv_label_set_text(ui->screen_1_label_20, string_temp[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_1_label_48, disp_work_mode_1[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_1_label_49, disp_work_mode_1[g_UserSet.Lauguage][1]);
	lv_label_set_text(ui->screen_1_label_50, disp_work_mode_1[g_UserSet.Lauguage][2]);
	lv_label_set_text(ui->screen_1_label_52, disp_menu_item[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_1_label_53, disp_menu_item[g_UserSet.Lauguage][1]);
	lv_label_set_text(ui->screen_1_label_54, disp_menu_item[g_UserSet.Lauguage][2]);
	lv_label_set_text(ui->screen_1_label_55, disp_menu_item[g_UserSet.Lauguage][3]);
	lv_label_set_text(ui->screen_1_label_56, disp_menu_item[g_UserSet.Lauguage][4]);
	lv_label_set_text(ui->screen_1_label_57, disp_menu_item[g_UserSet.Lauguage][5]);
	lv_label_set_text(ui->screen_1_btn_40_label, string_pm25_temp[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_1_label_3, string_hum[g_UserSet.Lauguage]);
    lv_label_set_text(ui->screen_1_label_16, disp_work_mode_2[g_UserSet.Lauguage][g_UserSet.TimerMode]);

    if ( g_UserSet.TimerMode == 0 ) {
        lv_img_set_src(ui->screen_1_img_44, &_lijia_alpha_30x30);
    } else if ( g_UserSet.TimerMode == 1 ) {
        lv_img_set_src(ui->screen_1_img_44, &_huijia_alpha_30x30);
    } else if ( g_UserSet.TimerMode == 2 ) {
        lv_img_set_src(ui->screen_1_img_44, &_sleep_alpha_30x30);
    } else{
        //do nothing  
    }

    if ( g_UserSet.f_On ) {
        lv_label_set_text(ui->screen_1_label_51, disp_switch[g_UserSet.Lauguage][1]);
        lv_obj_set_style_img_recolor_opa(ui->screen_1_img_37, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
    } else {
        lv_label_set_text(ui->screen_1_label_51, disp_switch[g_UserSet.Lauguage][0]);
        lv_obj_set_style_img_recolor_opa(ui->screen_1_img_37, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    }

    if ( g_UserSet.Mode == USER_SET_MODE_COOL )
    {
        lv_img_set_src(ui->screen_1_img_14, &_cool_round_alpha_270x270);
        lv_img_set_src(ui->screen_1_img_49, &_cool_alpha_25x25);
        lv_obj_set_style_img_recolor(ui->screen_1_img_49, lv_color_make(0x39, 0x68, 0xbe), LV_PART_MAIN|LV_STATE_DEFAULT);
    }
    else if ( g_UserSet.Mode == USER_SET_MODE_HEAT )
    {
        lv_img_set_src(ui->screen_1_img_14, &_heat_round_alpha_270x270);
        lv_img_set_src(ui->screen_1_img_49, &_heat_alpha_25x25);
        lv_obj_set_style_img_recolor(ui->screen_1_img_49, lv_color_make(0xe2, 0x68, 0x0f), LV_PART_MAIN|LV_STATE_DEFAULT);
    }
    else if ( g_UserSet.Mode == USER_SET_MODE_FAN )
    {
        lv_img_set_src(ui->screen_1_img_14, &_fan_round_alpha_270x270);
        lv_img_set_src(ui->screen_1_img_49, &_Fan_alpha_25x25);
        lv_obj_set_style_img_recolor(ui->screen_1_img_49, lv_color_make(0x3c, 0xcb, 0x4a), LV_PART_MAIN|LV_STATE_DEFAULT);
    }
    else
    {
        //do nothing
    }
    
    lv_obj_add_flag(ui->screen_1_label_2, LV_OBJ_FLAG_HIDDEN);
}

void lv_screen_2_update(void)
{
	char temp_buff[50] = {0};
    lv_ui *ui = &guider_ui;

	snprintf(temp_buff, 50, "%d", 
			g_UserSet.unit ? (temp_c2f(g_UserSet.SetTemp[USER_SET_MODE_HEAT])/10) : g_UserSet.SetTemp[USER_SET_MODE_HEAT]/10);
    lv_label_set_text(ui->screen_2_label_17, temp_buff);
    lv_label_set_text(ui->screen_2_label_100, g_UserSet.unit ? "℉" : "℃");

	lv_label_set_text(ui->screen_2_label_1, string_return[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_2_label_95, disp_menu_item[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_2_label_93, string_set_temp[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_2_label_5, string_mode_enum[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_2_label_7, string_mode_enum[g_UserSet.Lauguage][1]);
	lv_label_set_text(ui->screen_2_label_10, string_mode_enum[g_UserSet.Lauguage][2]);
	lv_label_set_text(ui->screen_2_label_23, string_setting_fan[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_2_label_24, string_setting_fan[g_UserSet.Lauguage][1]);
	lv_label_set_text(ui->screen_2_label_25, string_setting_fan[g_UserSet.Lauguage][2]);
	lv_label_set_text(ui->screen_2_label_26, string_setting_fan[g_UserSet.Lauguage][3]);

    int slider_val = ((g_UserSet.SetTemp[USER_SET_MODE_HEAT]/10) - 15) * 100 / 45;
    lv_slider_set_value(ui->screen_2_slider_1, slider_val ,LV_PART_MAIN);

    if ( g_UserSet.Mode == USER_SET_MODE_COOL )
    {
        lv_obj_set_style_bg_color(ui->screen_2_cont_7, lv_color_make(0x04, 0x4E, 0xCD), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_8, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_9, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
    }
    else if ( g_UserSet.Mode == USER_SET_MODE_HEAT )
    {
        lv_obj_set_style_bg_color(ui->screen_2_cont_7, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_8, lv_color_make(0x04, 0x4E, 0xCD), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_9, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
    }
    else if ( g_UserSet.Mode == USER_SET_MODE_FAN )
    {
        lv_obj_set_style_bg_color(ui->screen_2_cont_7, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_8, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_9, lv_color_make(0x04, 0x4E, 0xCD), LV_PART_MAIN|LV_STATE_DEFAULT);
    }
    else
    {
        //do nothing
    }

    if ( g_UserSet.Fan == 0 )
    {
        lv_obj_set_style_bg_color(ui->screen_2_cont_16, lv_color_make(0x04, 0x4E, 0xCD), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_17, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_18, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_19, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
    }
    else if ( g_UserSet.Fan == 1 )
    {
        lv_obj_set_style_bg_color(ui->screen_2_cont_16, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_17, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_18, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_19, lv_color_make(0x04, 0x4E, 0xCD), LV_PART_MAIN|LV_STATE_DEFAULT);
    }
    else if ( g_UserSet.Fan == 2 )
    {
        lv_obj_set_style_bg_color(ui->screen_2_cont_16, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_17, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_18, lv_color_make(0x04, 0x4E, 0xCD), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_19, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
    }
    else if ( g_UserSet.Fan == 3 )
    {
        lv_obj_set_style_bg_color(ui->screen_2_cont_16, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_17, lv_color_make(0x04, 0x4E, 0xCD), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_18, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
        lv_obj_set_style_bg_color(ui->screen_2_cont_19, lv_color_make(0x31, 0x38, 0x4A), LV_PART_MAIN|LV_STATE_DEFAULT);
    }
    else
    {
        //do nothing
    }
}

void lv_screen_3_update(void)
{
	char temp_buff[50] = {0};
    lv_ui *ui = &guider_ui;

	lv_label_set_text(ui->screen_3_label_58, string_return[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_3_label_92, disp_menu_item[g_UserSet.Lauguage][3]);
	lv_label_set_text(ui->screen_3_label_5, disp_work_mode_1[g_UserSet.Lauguage][1]);
	lv_label_set_text(ui->screen_3_label_7, disp_work_mode_1[g_UserSet.Lauguage][2]);
	lv_label_set_text(ui->screen_3_label_10, disp_work_mode_1[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_3_label_30, string_hum[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_3_label_31, string_fan_speed[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_3_label_32, string_out_fan_temp[g_UserSet.Lauguage]);

	snprintf(temp_buff, 50, "%s 08:00", disp_switch_time[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_3_label_28, temp_buff);
	snprintf(temp_buff, 50, "%s 18:00", disp_switch_time[g_UserSet.Lauguage][1]);
	lv_label_set_text(ui->screen_3_label_29, temp_buff);

	snprintf(temp_buff, 50, "%d", g_UserSet.unit ? (temp_c2f(280)/10) : 28);
    lv_label_set_text(ui->screen_3_label_19, temp_buff);
	lv_label_set_text(ui->screen_3_label_104, g_UserSet.unit ? "℉" : "℃");

	snprintf(temp_buff, 50, "%d%s", 
			g_UserSet.unit ? (temp_c2f(250)/10) : 25,
			g_UserSet.unit ? "℉" : "℃");
    lv_label_set_text(ui->screen_3_label_35, temp_buff);
}

void lv_screen_4_update(void)
{
	char temp_buff[50] = {0};
    lv_ui *ui = &guider_ui;

	lv_label_set_text(ui->screen_4_label_47, string_return[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_4_label_46, disp_menu_item[g_UserSet.Lauguage][4]);
	lv_label_set_text(ui->screen_4_label_36, string_set_temp[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_4_label_5, disp_screen_4_item_1[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_4_label_7, disp_screen_4_item_1[g_UserSet.Lauguage][1]);
	lv_label_set_text(ui->screen_4_label_10, disp_screen_4_item_1[g_UserSet.Lauguage][2]);
	lv_label_set_text(ui->screen_4_label_38, disp_screen_4_item_1[g_UserSet.Lauguage][3]);
	lv_label_set_text(ui->screen_4_label_39, disp_screen_4_item_1[g_UserSet.Lauguage][4]);
	lv_label_set_text(ui->screen_4_label_40, disp_screen_4_item_1[g_UserSet.Lauguage][5]);
	lv_label_set_text(ui->screen_4_label_41, disp_screen_4_item_1[g_UserSet.Lauguage][6]);
	lv_label_set_text(ui->screen_4_label_42, disp_screen_4_item_2[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_4_label_43, disp_screen_4_item_2[g_UserSet.Lauguage][1]);
	lv_label_set_text(ui->screen_4_label_44, disp_screen_4_item_2[g_UserSet.Lauguage][2]);
	lv_label_set_text(ui->screen_4_label_45, disp_screen_4_item_2[g_UserSet.Lauguage][3]);
	lv_label_set_text(ui->screen_4_label_37, string_mode_enum[g_UserSet.Lauguage][2]);
	lv_label_set_text(ui->screen_4_label_30, string_temp[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_4_label_31, string_hum[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_4_label_32, string_dew_point_temp[g_UserSet.Lauguage]);

	snprintf(temp_buff, 50, "%d%s", 
			g_UserSet.unit ? (temp_c2f(280)/10) : 28,
			g_UserSet.unit ? "℉" : "℃");
    lv_label_set_text(ui->screen_4_label_19, temp_buff);

	snprintf(temp_buff, 50, "%d%s", 
			g_UserSet.unit ? (temp_c2f(330)/10) : 33,
			g_UserSet.unit ? "℉" : "℃");
    lv_label_set_text(ui->screen_4_label_33, temp_buff);

	snprintf(temp_buff, 50, "%d%s", 
			g_UserSet.unit ? (temp_c2f(300)/10) : 30,
			g_UserSet.unit ? "℉" : "℃");
    lv_label_set_text(ui->screen_4_label_35, temp_buff);
}

void lv_screen_5_update(void)
{
	uint8_t i = 0;
	char temp_buff[50] = {0};
    lv_ui *ui = &guider_ui;
	lv_obj_t *name[14] = {
		ui->screen_5_label_59, ui->screen_5_label_61, ui->screen_5_label_66, ui->screen_5_label_68,
		ui->screen_5_label_70, ui->screen_5_label_72, ui->screen_5_label_74, ui->screen_5_label_76,
		ui->screen_5_label_78, ui->screen_5_label_80, ui->screen_5_label_82, ui->screen_5_label_84,
		ui->screen_5_label_86, ui->screen_5_label_88
	};
	lv_obj_t *value[14] = {
		ui->screen_5_label_60, ui->screen_5_label_65, ui->screen_5_label_67, ui->screen_5_label_69,
		ui->screen_5_label_71, ui->screen_5_label_73, ui->screen_5_label_75, ui->screen_5_label_77,
		ui->screen_5_label_79, ui->screen_5_label_81, ui->screen_5_label_83, ui->screen_5_label_85,
		ui->screen_5_label_87, ui->screen_5_label_89
	};

	lv_label_set_text(ui->screen_5_label_47, string_return[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_5_label_46, disp_menu_item[g_UserSet.Lauguage][1]);
	lv_label_set_text(ui->screen_5_label_5, disp_screen_5_item_1[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_5_label_7, disp_screen_5_item_1[g_UserSet.Lauguage][1]);
	lv_label_set_text(ui->screen_5_label_10, disp_screen_5_item_1[g_UserSet.Lauguage][2]);
	lv_label_set_text(ui->screen_5_label_38, disp_screen_5_item_1[g_UserSet.Lauguage][3]);
	lv_label_set_text(ui->screen_5_label_39, disp_screen_5_item_1[g_UserSet.Lauguage][4]);
	lv_label_set_text(ui->screen_5_btn_36_label, disp_paging[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_5_btn_37_label, disp_paging[g_UserSet.Lauguage][1]);

	snprintf(temp_buff, 50, "1/1");
	lv_label_set_text(ui->screen_5_label_91, temp_buff);

	for ( i = 0; i < 14; i++)
	{
		snprintf(temp_buff, 50, "%s%d:", string_status_param[g_UserSet.Lauguage], i + 1);
		lv_label_set_text(name[i], temp_buff);
	}
}

void lv_screen_6_update(void)
{
    lv_ui *ui = &guider_ui;
	char temp_buff[50] = {0};
    int16_t reg_value = 0, *pRegAddr = NULL;
    uint16_t tmp_PageCnt = 0, word_size = 0, index = 0, i = 0;
	disp_ui_word_t *disp_ui_word = NULL;
	lv_obj_t *name[14] = {
		ui->screen_6_label_59, ui->screen_6_label_61, ui->screen_6_label_66, ui->screen_6_label_68,
		ui->screen_6_label_70, ui->screen_6_label_72, ui->screen_6_label_74, ui->screen_6_label_76,
		ui->screen_6_label_78, ui->screen_6_label_80, ui->screen_6_label_82, ui->screen_6_label_84,
		ui->screen_6_label_86, ui->screen_6_label_88
	};
	lv_obj_t *value[14] = {
		ui->screen_6_label_60, ui->screen_6_label_65, ui->screen_6_label_67, ui->screen_6_label_69,
		ui->screen_6_label_71, ui->screen_6_label_73, ui->screen_6_label_75, ui->screen_6_label_77,
		ui->screen_6_label_79, ui->screen_6_label_81, ui->screen_6_label_83, ui->screen_6_label_85,
		ui->screen_6_label_87, ui->screen_6_label_89
	};

	lv_label_set_text(ui->screen_6_label_47, string_return[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_6_label_46, disp_menu_item[g_UserSet.Lauguage][2]);
	lv_label_set_text(ui->screen_6_label_5, disp_screen_6_item_1[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_6_label_7, disp_screen_6_item_1[g_UserSet.Lauguage][1]);
	lv_label_set_text(ui->screen_6_label_10, disp_screen_6_item_1[g_UserSet.Lauguage][2]);
	lv_label_set_text(ui->screen_6_label_38, disp_screen_6_item_1[g_UserSet.Lauguage][3]);
	lv_label_set_text(ui->screen_6_label_39, disp_screen_6_item_1[g_UserSet.Lauguage][4]);
	lv_label_set_text(ui->screen_6_btn_36_label, disp_paging[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_6_btn_37_label, disp_paging[g_UserSet.Lauguage][1]);

	for ( i = 0; i < 14; i++)
	{
		snprintf(temp_buff, 50, "%s%d:", string_set_param[g_UserSet.Lauguage], i + 1);
		lv_label_set_text(name[i], temp_buff);
	}

	snprintf(temp_buff, 50, "1/1");
	lv_label_set_text(ui->screen_6_label_91, temp_buff);

    disp_ui_word = (disp_ui_word_t *)seting0_ui_word;
    word_size = seting0_ui_word_size;

	tmp_PageCnt = word_size / 5;
    tmp_PageCnt += (word_size % 5) ? 1 : 0;
    if(g_UserSet.setting_cur_page > (tmp_PageCnt - 1)){
        g_UserSet.setting_cur_page = 0;
    }else if(g_UserSet.setting_cur_page < 0){
        g_UserSet.setting_cur_page = tmp_PageCnt - 1;
    }
	g_UserSet.setting_total_page = tmp_PageCnt ? tmp_PageCnt : 1;
	index = g_UserSet.setting_cur_page * 5;

	// // sprintf(temp_buff, "%d/%d", g_UserSet.setting_cur_page + 1, g_UserSet.status_total_page);
	// // lv_label_set_text(ui->screen_status_label_11, temp_buff);

	// for (i = 0; i < 5; i++){
	// 	lv_label_set_text(setting_list_name[i], ((index + i) < word_size) ? disp_ui_word[index + i].name[g_UserSet.Lauguage] : "");

	// 	if((index + i) < word_size){
	// 		pRegAddr = (int16_t *)find_addr_index(0, disp_ui_word[index + i].word);
	// 		if(pRegAddr){
	// 			reg_value = (*pRegAddr >> disp_ui_word[index + i].start) & ((1 << disp_ui_word[index + i].len) - 1);
	// 		}else{
	// 			reg_value = 0;
	// 		}
	// 		fun_draw_ui_word(&disp_ui_word[index + i], temp_buff, reg_value);
    //         lv_obj_clear_flag(setting_list_img[i][0], LV_OBJ_FLAG_HIDDEN);
    //         lv_obj_clear_flag(setting_list_img[i][1], LV_OBJ_FLAG_HIDDEN);
	// 	}else{
	// 		memset(temp_buff, 0, sizeof(temp_buff));
    //         lv_obj_add_flag(setting_list_img[i][0], LV_OBJ_FLAG_HIDDEN);
    //         lv_obj_add_flag(setting_list_img[i][1], LV_OBJ_FLAG_HIDDEN);
	// 	}
	// 	lv_label_set_text(setting_list_value[i], temp_buff);
	// }
}

void lv_screen_7_update(void)
{
	char temp_buff[50] = {0};
    lv_ui *ui = &guider_ui;

	lv_label_set_text(ui->screen_7_label_47, string_return[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_7_label_46, disp_menu_item[g_UserSet.Lauguage][5]);
	lv_label_set_text(ui->screen_7_label_5, disp_screen_7_item_1[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_7_label_7, disp_screen_7_item_1[g_UserSet.Lauguage][1]);
	lv_label_set_text(ui->screen_7_label_10, disp_screen_7_item_1[g_UserSet.Lauguage][2]);

	lv_label_set_text(ui->screen_7_label_98, disp_ui_set[8].name[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_7_label_99, disp_ui_set[6].name[g_UserSet.Lauguage]);

	lv_label_set_text(ui->screen_7_btn_38_label, set_enum6[g_UserSet.unit].name[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_7_btn_39_label, set_enum4[g_UserSet.Lauguage].name[g_UserSet.Lauguage]);
}

void lv_screen_8_update(void)
{
    lv_ui *ui = &guider_ui;

	lv_label_set_text(ui->screen_8_label_47, string_return[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_8_label_46, disp_menu_item[g_UserSet.Lauguage][5]);
	lv_label_set_text(ui->screen_8_label_5, disp_screen_7_item_1[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_8_label_7, disp_screen_7_item_1[g_UserSet.Lauguage][1]);
	lv_label_set_text(ui->screen_8_label_10, disp_screen_7_item_1[g_UserSet.Lauguage][2]);
}

void lv_screen_9_update(void)
{
    lv_ui *ui = &guider_ui;

	lv_label_set_text(ui->screen_9_label_47, string_return[g_UserSet.Lauguage]);
	lv_label_set_text(ui->screen_9_label_46, disp_menu_item[g_UserSet.Lauguage][5]);
	lv_label_set_text(ui->screen_9_label_5, disp_screen_7_item_1[g_UserSet.Lauguage][0]);
	lv_label_set_text(ui->screen_9_label_7, disp_screen_7_item_1[g_UserSet.Lauguage][1]);
	lv_label_set_text(ui->screen_9_label_10, disp_screen_7_item_1[g_UserSet.Lauguage][2]);
}

void lv_main_refresh(void)
{
	lv_disp_t * d = lv_obj_get_disp(lv_layer_top());

	if (d->act_scr == guider_ui.screen_1){
        lv_screen_1_update();
        // ESP_LOGI("lv", "lv_screen_1_update...\r\n");
    }else if(d->act_scr == guider_ui.screen_2){
        lv_screen_2_update();
        // ESP_LOGI("lv", "lv_screen_2_update...\r\n");
    }else if(d->act_scr == guider_ui.screen_3){
        lv_screen_3_update();
        // ESP_LOGI("lv", "lv_screen_3_update...\r\n");
    }else if(d->act_scr == guider_ui.screen_4){
        lv_screen_4_update();
        // ESP_LOGI("lv", "lv_screen_4_update...\r\n");
    }else if(d->act_scr == guider_ui.screen_5){
        lv_screen_5_update();
        // ESP_LOGI("lv", "lv_screen_5_update...\r\n");
    }else if(d->act_scr == guider_ui.screen_6){
        lv_screen_6_update();
        // ESP_LOGI("lv", "lv_screen_6_update...\r\n");
    }else if(d->act_scr == guider_ui.screen_7){
        lv_screen_7_update();
        // ESP_LOGI("lv", "lv_screen_7_update...\r\n");
    }else if(d->act_scr == guider_ui.screen_8){
        lv_screen_8_update();
        // ESP_LOGI("lv", "lv_screen_8_update...\r\n");
    }else if(d->act_scr == guider_ui.screen_9){
        lv_screen_9_update();
        // ESP_LOGI("lv", "lv_screen_9_update...\r\n");
    }

    if(g_UserSet.blk_time_count == 0){//黑屏了
        if(d->act_scr != guider_ui.screen_1){
            lv_scr_load_anim(guider_ui.screen_1, LV_SCR_LOAD_ANIM_OVER_TOP, 0, 0, false);
        }
    }
}

void lv_setting_value(int index, int dir)
{
	disp_ui_word_t *disp_ui_word = 0;
    int16_t reg_value = 0, *pRegAddr = NULL, word_size = 0, index2 = 0, i = 0;

    disp_ui_word = (disp_ui_word_t *)seting0_ui_word;
    word_size = seting0_ui_word_size;

    index2 = g_UserSet.setting_cur_page * 5 + (index - 1);
    if(index2 >= word_size){
        return ;
    }

    pRegAddr = (int16_t *)find_addr_index(0, disp_ui_word[index2].word);
    if(pRegAddr){
        reg_value = (*pRegAddr >> disp_ui_word[index2].start) & ((1 << disp_ui_word[index2].len) - 1);
        reg_value = reg_value + dir;
        *pRegAddr = set_bits(*pRegAddr, disp_ui_word[index2].start, disp_ui_word[index2].len, reg_value);
    }

    // if(*pRegAddr < disp_ui_word[index2].min){
    //     *pRegAddr = disp_ui_word[index2].min;
    // }
    // if(*pRegAddr > disp_ui_word[index2].max){
    //     *pRegAddr = disp_ui_word[index2].max;
    // }

	g_UserSet.PrjSetDev = 0;
	g_UserSet.PrjSetAddr = disp_ui_word[index2].word;
	g_UserSet.PrjSetValue = *pRegAddr;
	g_UserSet.PrjSetFlag = 3;
	g_UserSet.Updata2Network = 3;
}

char *lv_get_date_time(void)
{
    static char time_buff[50] = {0};
    time_t timer0;
    timer0 = time(NULL);
    struct tm *plocaltime = localtime(&timer0);
    sprintf(time_buff, "%04d/%02d/%02d %02d:%02d:%02d", 
            plocaltime->tm_year + 1900, 
            plocaltime->tm_mon + 1, 
            plocaltime->tm_mday, 
            plocaltime->tm_hour, 
            plocaltime->tm_min, 
            plocaltime->tm_sec);
    return time_buff;
}

int temp_f2c(int f)
{
    int c = 0;
    c = (f - 320) * 5 / 9;
    // if(c % 10 >= 5){
    //     c = (c - (c % 10)) + 10;
    // }else{
    //     c -= (c % 10);
    // }
    return c;
}

int temp_c2f(int c)
{
    int f = 0;
    f = 320 + (c * 9 / 5);
    if(f % 10 >= 5){
        f = (f - (f % 10)) + 10;
    }else{
        f -= (f % 10);
    }
    return f;
}

void lv_timer_callback(lv_timer_t *timer)
{
    lv_main_refresh();
}

void guider_init(void)
{
    lv_timer_t * lv_timer;
    setup_ui(&guider_ui);
    events_init(&guider_ui);
    custom_init(&guider_ui);
    lv_timer = lv_timer_create(lv_timer_callback, 500, NULL);
}
